﻿using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using LiveCharts.Definitions.Points;
using LiveCharts.Definitions.Series;
using LiveCharts.Dtos;
using LiveCharts.SeriesAlgorithms;
using LiveCharts.Wpf;

namespace LiveCharts.Wpf
{
 
	public class GColumnSeries : GearedSeries, ISeriesView, IColumnSeriesView
	{
		public GColumnSeries()
		{
			base.Model = new ColumnAlgorithm(this);
			this.method_2();
		}

		public GColumnSeries(object configuration)
		{
			base.Model = new ColumnAlgorithm(this);
			base.Configuration = configuration;
			this.method_2();
		}

	 
		public double MaxColumnWidth
		{
			get
			{
				return (double)base.GetValue(GColumnSeries.MaxColumnWidthProperty);
			}
			set
			{
				base.SetValue(GColumnSeries.MaxColumnWidthProperty, value);
			}
		}

	 
		public double ColumnPadding
		{
			get
			{
				return (double)base.GetValue(GColumnSeries.ColumnPaddingProperty);
			}
			set
			{
				base.SetValue(GColumnSeries.ColumnPaddingProperty, value);
			}
		}

	 
		public BarLabelPosition LabelsPosition
		{
			get
			{
				return (BarLabelPosition)base.GetValue(GColumnSeries.LabelsPositionProperty);
			}
			set
			{
				base.SetValue(GColumnSeries.LabelsPositionProperty, value);
			}
		}
 
		public bool SharesPosition
		{
			get
			{
				return (bool)base.GetValue(GColumnSeries.SharesPositionProperty);
			}
			set
			{
				base.SetValue(GColumnSeries.SharesPositionProperty, value);
			}
		}

		public override IChartPointView GetPointView(ChartPoint point, string label)
		{
			return this.method_3(point, label);
		}

		private void method_2()
		{
			base.SetCurrentValue(Series.StrokeThicknessProperty, 0.0);
			base.SetCurrentValue(GColumnSeries.MaxColumnWidthProperty, 35.0);
			base.SetCurrentValue(GColumnSeries.ColumnPaddingProperty, 2.0);
			base.SetCurrentValue(GColumnSeries.LabelsPositionProperty, BarLabelPosition.Top);
			Func<ChartPoint, string> value = new Func<ChartPoint, string>(this.method_4);
			base.SetCurrentValue(Series.LabelPointProperty, value);
			base.DefaultFillOpacity = 1.0;
			 
		}

		private IChartPointView method_3(ChartPoint chartPoint_0, string string_0)
		{
			Class6 @class = (Class6)chartPoint_0.View;
			if (@class == null)
			{
				Class6 class2 = new Class6();
				class2.IsNew = true;
				class2.method_1(new Class3());
				class2.Data = new CoreRectangle();
				@class = class2;
			}
			else
			{
				@class.IsNew = false;
				chartPoint_0.SeriesView.Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(@class.DataLabel);
			}
			if (base.DataLabels && @class.DataLabel == null)
			{
				@class.DataLabel = (@class.DataLabel = base.UpdateLabelContent(new DataLabelViewModel
				{
					FormattedText = string_0,
					Point = chartPoint_0
				}, @class.DataLabel));
			}
			if (!base.DataLabels && @class.DataLabel != null)
			{
				base.Model.Chart.View.RemoveFromDrawMargin(@class.DataLabel);
				@class.DataLabel = null;
			}
			@class.method_3(this.LabelsPosition);
			return @class;
		}

		[CompilerGenerated]
		private string method_4(ChartPoint chartPoint_0)
		{
			return base.Model.CurrentYAxis.GetFormatter()(chartPoint_0.Y);
		}

		public static readonly DependencyProperty MaxColumnWidthProperty = DependencyProperty.Register("MaxColumnWidth", typeof(double), typeof(GColumnSeries), new PropertyMetadata(0.0));

		public static readonly DependencyProperty ColumnPaddingProperty = DependencyProperty.Register("ColumnPadding", typeof(double), typeof(GColumnSeries), new PropertyMetadata(0.0));

		public static readonly DependencyProperty LabelsPositionProperty = DependencyProperty.Register("LabelsPosition", typeof(BarLabelPosition), typeof(GColumnSeries), new PropertyMetadata(BarLabelPosition.Top, Series.CallChartUpdater(false)));

		public static readonly DependencyProperty SharesPositionProperty = DependencyProperty.Register("SharesPosition", typeof(bool), typeof(GColumnSeries), new PropertyMetadata(true));
	}
}
